package cn.study.luckyadapter.controller.admin;

import cn.study.common.annotation.ResponseResult;
import cn.study.luckyclient.api.IRuleService;
import cn.study.luckyclient.dto.RuleAddCmd;
import cn.study.luckyclient.dto.RuleUpdateCmd;
import cn.study.luckyclient.dto.data.RuleVo;
import cn.study.luckyclient.dto.query.RuleListByParamQuery;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

@ResponseResult
@AllArgsConstructor
@RequestMapping("/admin/v1/rule")
public class AdminRuleController {
    private final IRuleService ruleService;
    @PostMapping("/add")
    public RuleVo add(@Validated @RequestBody RuleAddCmd ruleAddCmd){
        return ruleService.add(ruleAddCmd);
    }
    @PostMapping("/uddate")
    public RuleVo update(@Validated @RequestBody RuleUpdateCmd ruleUpdateCmd){
        return ruleService.update(ruleUpdateCmd);
    }
    @GetMapping("/page")
    public IPage<RuleVo> page(@RequestBody RuleListByParamQuery ruleListByParamQuery){
        return ruleService.query(ruleListByParamQuery);
    }
}
